<?php
error_reporting(0);
header("Access-Control-Allow-Origin:*");
require "dbutil/dbConnUtil.php";
$filmId = $_REQUEST["filmId"];

$sql = "select
                f.sortId , f.filmId , f.filmName , f.filmYear , f.filmTypes ,
                f.filmDesc , f.filmImg , f.castNames , f.castList , f.typeId ,
                avg(fc.userSource) source,count(f.filmId) count
            from
                film f
            left join
                film_comment fc
            on
                f.filmId = fc.filmId
            where f.filmId = $filmId
           ";

$result = mysqli_query($conn, $sql);

$resultArr = array();

if ($result && $result->num_rows >= 0) {

    //设置查询消息
    $resultArr["msg"] = "查询成功";
    //设置查询状态  true 表示查询成功
    $resultArr["resultState"] = true;

    $typeArr = null;

    $typeArr = mysqli_fetch_array($result, MYSQLI_ASSOC);
    $typeArr["castList"] = json_decode($typeArr["castList"],false);
    // 将查询结果放置在关联数组中
    $resultArr["result"] = $typeArr;
} else {

    $resultArr["info"] = mysqli_error($conn);
    $resultArr["msg"] = "查询失败";
    //设置查询状态  false  表示查询失败
    $resultArr["resultState"] = false;

    $resultArr["result"] = null;

}

echo json_encode($resultArr);
